
<%@include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/resources/js/datatable-query.js"></script>
<c:if test="${fn:length(categories)>0}">
<div class="row-fluid">
 <div class="span12">
				<div class="box">
					<div class="title">
 						<h4>
							<span class="icon16 icomoon-icon-filter"></span> <span>Filter</span>
						</h4>
						<a href="#" class="minimize">Minimize</a>
					</div>
					<div class="content clearfix form-horizontal">

						<div class="form-row row-fluid">
							<div class="span4">
								<label class="form-label span6">Category</label>
								<div class="span6 controls">
										<select field="category.id" class="filterdata" op="eq">
										<option value="">====================</option>
										 <c:if
														test="${not empty categories}">
														<c:forEach var="single" items="${categories}">
															<option value="${single.id}">${single.name}</option>
														</c:forEach>
										</c:if>

									</select>
								</div>
							</div>
										<div class="span4">
								<label class="form-label span6">Language</label>
								<div class="span6 controls">
										<select field="category.id" class="filterdata" op="eq">
										<option value="">===</option>
										 <c:if
														test="${not empty categories}">
														<c:forEach var="single" items="${languages}">
															<option value="${single.id}">${single.name}</option>
														</c:forEach>
										</c:if>

									</select>
								</div>
							</div>
							</div>
 
				 
						<hr />


					</div>
				</div>
		 
		</div>
</div>
</c:if>
<div class="row-fluid">
<div class="span12">
<div class="box gradient">
<div class="title">
<h4><span>Article</span> <span class="box-form right"></span>

</h4>
<a href="#" class="minimize">Minimize</a></div>
<div class="content scrollable clearfix">
<table class="ajaxTable display table table-bordered">
	<thead>
		<tr>
			<th><a id="select_all"><span class="icomoon-icon-checkmark-2"></span></a></th>
			<th>Title</th>
			<th>Author</th>
			<th>Create Time</th>
			<th>Effect Day</th>
			<th>URL</th>
			<th>Online</th>
			<th>Action</th>
		</tr>
	</thead>
</table>
</div>
</div>

</div>
</div>
<shiro:hasPermission name="article:create">
	<a href="${ctx}/admin/article/create/" class="btn btn-info"> <span
		class="icon12 icomoon-icon-plus white"></span> New</a>
</shiro:hasPermission>
</div>

<c:choose>
 <c:when test="${urlConfig.format ne null }">
<c:set var="url_format" value="${urlConfig.format}" />
</c:when>
<c:otherwise>
<c:set var="url_format" value="LG-en/resource-article/view/{0}" />
</c:otherwise>
</c:choose>
<c:if test=""></c:if>


<script type="text/javascript">
var render = false;

 $(document).ready(function () {
	johnny.oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"sAjaxSource": '${ctx}/admin/article/',
		"aoColumnDefs": [
			       		  { 'bSortable': false, 'aTargets': [0,3] }
			       		],
		"fnInitComplete": function (oSettings, json) { }
	});
	var name = $("<input>").attr({
		type: "text",
		field: "title",
		op: "cn",
		placeholder: "Title",
		class: "filterdata"
	});
	johnny.initTableQuery(name);
	var config = {
			id : 'del',
			text  : 'Del',
			domain : "Article",
			operation : "Delete",
			url : "${ctx}/admin/article/del/"
	};
	johnny.tableBtn(config);
	
	var online = {
			id : 'online',
			text : 'online',
			domain : "Post",
			operation : "Online",
			url : "${ctx}/admin/article/online/"
		};
		johnny.tableBtn(online);

		var offline = {
			id : 'offline',
			text : 'offline',
			domain : "Post",
			operation : "Offline",
			url : "${ctx}/admin/article/offline/"
		};
		johnny.tableBtn(offline);
	
	
	
	
 });
 
var columnHeader = ['','title', 'user.name', 'createDate','effectDay','keyUrl','online'];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}

var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		var subArray = new Array();
		var value = johnny.getForSelect(json.result[i].id);
 		subArray.push(value);

 		var format = "${url_format}";
 		
		var view = "${ctx}/"+format.replace("{0}",json.result[i].id);
 		var link = "${ctx}/admin/article/"+json.result[i].id+"/edit/";
		var detail = "${ctx}/admin/article/"+json.result[i].id+"/detail/";
 		
		subArray.push(json.result[i].title);
		if (json.result[i].user){
			subArray.push(json.result[i].user.name);			
		}else{
			subArray.push("");			
		}
		subArray.push(json.result[i].createDate);
		subArray.push(json.result[i].effectDay);
		subArray.push(json.result[i].keyUrl);
		subArray.push(json.result[i].online);
		
		
		
		var conf = [
			{
				link : view,
				text : 'view',
				css  : 'minia-icon-eye'
				
			},		            
		            
          {
			link : link,
			text : 'inline',
			target:  "_blank",
			css   : 'icomoon-icon-eyedropper',
 			sub   : [<c:forEach varStatus="loop" var="single"  items="${languages}">{target:'_blank', name :'<c:out value="${single.language}"></c:out>',url :  "${ctx}/admin/article/"+json.result[i].id+"/lg/${single.id}/edit/"}<c:if test="${!loop.last}">,</c:if></c:forEach>]	
			
			
			},
		{
			link : detail,
			text : 'detail',
			css   : 'icomoon-icon-pencil'
			
		}];
		subArray.push(johnny.getGridLink(conf));
		dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
} 
</script>



<body>